import { HttpClientModule, HttpClient, HttpHeaders } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { User } from './../Model/User';
import { Component, OnInit, Input} from '@angular/core';
import {
  FormBuilder,
  FormGroup,
  Validators,
  ReactiveFormsModule, 
  FormControl,
  FormControlName
} from '@angular/forms';
@Component({
  selector: 'login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
  public validateForm: FormGroup;

  @Input()
  nzValidateStatus:FormControlName;

  _submitForm() {
    for (const i in this.validateForm.controls) {
      this.validateForm.controls[i].markAsDirty();
    }

    this.http.post('http://localhost:81/Home/Test',JSON.stringify(this.validateForm.value),{
      headers: new HttpHeaders().set('Content-Type', 'application/json'),
    })
    .subscribe(data=>{
      console.log(data);
    });

  }

  constructor(private fb: FormBuilder,private http:HttpClient) {
  }

  ngOnInit() {
    this.validateForm = this.fb.group({
      userName: [null, Validators.required],
      password: [null, Validators.required],
      remember: [true],
    });
  }

}
